Turbo C Context File w H KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP KEYBOARD.CPP IMAGES.CPP IDEMO.CPP D:\WORKSHOP\SOURCE\*.C D:\WORKSHOP\SOURCE\*.*] D:\WORKSHOP\SOURCE\*.* *.CPP input_status_1 vbi_mask static current_font *.CPP cycle palette[i][j]/cycle fade_adj[i-1][j-1] palette palette[i][j] current current[i][j] fade_adj fade_adj[i][j] gradient readsize mapsize D:\WORKSHOP\SOURCE\NONAME00.CPP D:\COMM\TAPCIS\WORKING\DDJFORUM.SAV D:\WORKSHOP\SOURCE\PTRDEMO.CPP D:\MARK4\TEST.CPP D:\MARK4\DESIGN.TXT D:\MARK4\EGA.ASM D:\WORKSHOP\SOURCE\BALLTEST.CPP D:\WORKSHOP\13KIT\IDEMO.CPP D:\WORKSHOP\13KIT\KEYBOARD.HPP D:\WORKSHOP\13KIT\KEYBOARD.HPP D:\WORKSHOP\13KIT\IDEMO.CPP D:\WORKSHOP\13KIT\IMAGES.HPP D:\WORKSHOP\13KIT\KEYBOARD.CPP D:\WORKSHOP\13KIT\IMAGES.CPP )YFILE *Pcx; // file pointer PcxHdr *Header; // header structure FILE *Pcx; // file pointer ColorReg Palette[255]; // palette structure #include main(){int k,i,s=0,j,d;char c;do{clrscr();gotoxy(38,6);printf("+ +"); for(i=1;i<=80;i++){for(d=1;d<1000;d++);gotoxy(1,1);printf("SCORE = %d ",s); gotoxy(i-1,14);printf(" ");gotoxy(i,14);printf("&");if(kbhit()){c=getch(); if(c==32){for(j=13;j>=6;j--){gotoxy(i,j+1);printf(" ");gotoxy(i,j); printf(".");if(j==7)((i==38)||(i==40))?s--:i==39?s++:s;}}}}}while(c!=27);} bar((xdim*5),(ydim*5),((xdim*5)+5),((ydim*5)+5)); maze[xdim][ydim] = 1; extern void _loadpalette(int start, int number, PRec* palette); extern void _readpalette(int start, int number, PRec* palette); unsigned int i; if ((start>255) | (start<0) | ((start+number)>255)) return(0); for (i=start,i=(start+number),i++) { asm cli; portb(0x3C8) = i; portb(0x3C9) = palette->RGB[i].Red; portb(0x3C9) = palette->RGB[i].Green; portb(0x3C9) = palette->RGB[i].Blue; asm sti; portb(0x3C9) = portb(0x3C9) = portb(0x3C9) = void clrscr(int color) void barfill(int tlx, int tly, int brx, int bry, int color) void _setgraphseg(unsigned int newseg) ,PRec *Palette ,PRec *Palette void UnpackPcx(char far *Source, char far *Dest, unsigned int NumBytes) FILE *InitPcxFile(char *Fspec,PRec *Palette,struct PcxHdr *Header) extern "C" mlevel::mlevel() { int i,j; for(i=0;i<64;i++) { for(j=0;j<40;j++) { maze[i][j].type = 0; } MicrosoftMouse MM; // Only instance allowed! MicrosoftMouse MM; // Only instance allowed! //************************************************************************** // IMAGES.CPP -source file for basic video operations in mode 0x13. * // Copyright 1991 by the Gamers Programming Workshop, a function of the * // GAMERS forum, Compuserve. For more info e-mail 76605,2346. * // * // License is granted for use or modification of this code as long as * // this notice remains intact, and all improvements are listed in the * // version history below, and uploaded to the GAMERS forum. This code * // may not be used for any commercial purpose. * // * // PCX stuff adapted from "BitMapped Graphics" by Steve Rimmer (1990 * // Windcrest) * //************************************************************************** //************************************************************************** // Version history: * // * // Version 1.0 * // Developed: May 2, 1991 * // Author: Mark Betz, 76605, 2346 * // Last update: May 30, 1991 * //************************************************************************** // KEYBOARD.CPP ************************************************************ // module for low level filtered and unfiltered keyboard i/o. * // Copyright 1991 by the Gamers Programming Workshop, a function of the * // GAMERS forum, Compuserve. For more info e-mail 76605,2346. * // * // License is granted for use or modification of this code as long as * // this notice remains intact, and all improvements are listed in the * // version history below, and uploaded to the GAMERS forum. This code * // may not be used for any commercial purpose. * // * // PCX stuff adapted from "BitMapped Graphics" by Steve Rimmer (1990 * // Windcrest) * //************************************************************************** //************************************************************************** // Version history: * // * // Version 1.0 * // Developed: May 30, 1991 * // Author: Mark Betz, 76605, 2346 * // Last update: May 30, 1991 * //************************************************************************** void stuffbuffer(key_event *event); for(j=0;jgetstatus()!=Success)) { printf("error creating navaho.pcx object"); return(1); picture = new pcx("newtut.pcx"); if ((picture==NULL)||(picture->getstatus()!=Success)) { printf("error creating newtut.pcx object"); return(1); waitkey(); picture->remove(SoftFade); picture->display(SoftFade); delete(picture); The constant 64000 and the expression (for instance) 6400*10 are not the same value. The former, being positive and > 32767, is interpreted by the compiler as a long (and is positive). The latter is computed to 16 bits only, with the result representing a 16-bit negative value. When you do (unsigned)64000 I'm not sure offhand what you get. Compile this program in small model and note the result; then remove all occurrences of the keyword huge and compile in large model and note the (different) result. #include #include #include int main(void) char huge *ptr; ptr = (char huge *) MK_FP(0xa000, 0x0000); printf("ptr = %Fp\n", ptr); ptr = ptr + 64000; /* warning generated here */ printf("ptr = %Fp\n", ptr); ptr = (char huge *) MK_FP(0xa000, 0x0000); printf("ptr = %Fp\n", ptr); ptr = ptr + 6400*10; printf("ptr = %Fp\n", ptr); return 0; Gary {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0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0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, { {0, 0, 0,10,10,10,10, 0, 0, 0}, {0, 0,13,10,10,10,10,11, 0, 0}, {0, 0,13,10,10,10,10,11, 0, 0}, {0, 0,13,13, 0, 0,11,11, 0, 0}, {0, 0,13,12,12,12,12,11, 0, 0}, {0, 0,13,12,12,12,12,11, 0, 0}, {0, 0, 0,12,12,12,12, 0, 0, 0} }, { {0, 0, 0, 0,10,10, 0, 0, 0, 0}, {0, 0, 0,10,10,10,10, 0, 0, 0}, {0, 0,13,10,10,10,10,11, 0, 0}, {0, 0,13,13, 0, 0,11,11, 0, 0}, {0, 0,13,12,12,12,12,11, 0, 0}, {0, 0, 0,12,12,12,12, 0, 0, 0}, {0, 0, 0, 0,12,12, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0,10,10, 0, 0, 0, 0}, {0, 0, 0,10,10,10,10, 0, 0, 0}, {0, 0,13,13, 0, 0,11,11, 0, 0}, {0, 0, 0,12,12,12,12, 0, 0, 0}, {0, 0, 0, 0,12,12, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0,10,10, 0, 0, 0, 0}, {0, 0, 0,13, 0, 0,11, 0, 0, 0}, {0, 0, 0, 0,12,12, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0,10,10, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, extern void unpackpcx(FILE *pcx, const char far *source, char far *dest, unsigned int num_bytes); // **** System level graphics functions *********************************** extern void setgraphmode(); extern void settextmode(); extern void wait_vbi(); extern void reporterr(char type, char where[30]); // **** DAC palette functions ********************************************* extern void loadpalette(int start, int number, const p_rec palette); extern void readpalette(int start, int number, p_rec palette); extern void clrpalette(int start, int number); extern void fadepalettein(int start, int count, const p_rec palette); extern void fadepaletteout(int start, int count); // **** Graphics segment redirection ************************************** extern void setgraphseg(unsigned newseg); // **** Drawing primitives ************************************************ extern void clearscr(int color); extern void barfill(int tlx, int tly, int brx, int bry, int color); extern void writepixel(int x, int y, int color); extern char readpixel(int x, int y); extern void far *xy_to_ptr(int x, int y); extern void line(int x0, int y0, int x1, int y1, int color); // **** Image block copying functions ************************************* extern void getimage(int x0, int y0, int x1, int y1, char far *buff); extern void putimage(int x0, int y0, int x1, int y1, char far *buff); extern void copyimage(int x0, int y0, int x1, int y1, int putx, int puty, void far *src_buf); // **** Image fades and dissolve functions ******************************** extern void doSplitVerticalWipe(void far *pic_buf); extern void doSplitHorizWipe(void far *pic_buf); extern void doSlideVerticalWipe(void far *pic_buf); extern void doSlideHorizWipe(void far *pic_buf); extern void doVerticalDissolve(void far *pic_buf); extern void doHorizDissolve(void far *pic_buf); extern void doSparkleDissolve(void far *pic_buf); // image fade constants *************************************************** const char SnapWipe = 0; // simple block copy to vram const char SplitVerticalWipe = 1; // fades from top and bottom const char SplitHorizWipe = 2; // fades from right and left const char SlideVerticalWipe = 3; // slides image in from right and left const char SlideHorizWipe = 4; // slides image in from top and bottom const char VerticalDissolve = 5; // fades multiple vertical slices const char HorizDissolve = 6; // fades multiple horizontal slices const char SparkleDissolve = 7; // fades with random pixel placement const char SoftFade=8; // does a palette shifted fade // error reporting constants ********************************************** const char NoErr = 0; // no error occured const char MemErr = 1; // error occured allocating memory const char FileReadErr = 2; // error occured reading a file const char FileWriteErr = 3; // error occured writing a file const char FileMakeErr = 4; // error occured creating a file const char FileOpenErr = 5; // error occured opening file const char FileFormatErr = 6; // bad file format error const char SecondaryErr = 7; // error occured in subroutine during call const char UnknownErr = 8; // an unknown error occured // For use with type PRec ************************************************* const short Red = 0; // constants used with type PRec const short Green = 1; // example: PRec Palette; const short Blue = 2; // Palette[0][Green]=63; // for use with call to pcx::load() *************************************** const char Packed = 0; // load image in compressed form const char Unpacked = 1; // load image in uncompressed form const char Bestfit = 2; // load compressed or uncompressed static unsigned int GRAPH_SEG = 0xA000; // segment for video operations static p_rec current; // palette record for fades extern void getkey(char *key, extnd *scan); extern boolean getfilteredkey(char mask, char *key, extnd *scan); extern void stuffbuffer(char key, extnd scan); extern void flushBuffer(char *buf); enum boolean {false,true}; // keyboard constants for special keys ************************************* // prefixes: C_ : Ctrl and key // S_ : Shift and key // A_ : Alt and key example: A_F2 = alt-f2 // ************************************************************************* enum extnd {F1=59,F2,F3,F4,F5,F6,F7,F8,F9,F10, F11=133,F12, S_F1=84,S_F2,S_F3,S_F4,S_F5,S_F6,S_F7,S_F8,S_F9,S_F10, S_F11=135,S_F12, C_F1=94,C_F2,C_F3,C_F4,C_F5,C_F6,C_F7,C_F8,C_F9,C_F10, C_F11=137,C_F12, A_F1=104,A_F2,A_F3,A_F4,A_F5,A_F6,A_F7,A_F8,A_F9,A_F10, A_F11=139,A_F12, S_TAB=15, HOME=71,UP_ARR,PG_UP,LT_ARR=75,RT_ARR=77,END=79,DN_ARR, PG_DN,INS,DEL, C_PRTSC=114,C_LT_ARR,C_RT_ARR,C_END,C_PG_DN,C_HOME, C_PG_UP=132, NO_EXT=0}; // ************************************************************************* // mask types passed to getfilteredkey() to select keymask. Masks operate // as follows: U_CASE - returns only upper case characters // L_CASE - returns only lower case characters // B_CASE - returns characters of both cases // NUMBER - returns only numbers // FUNCT - returns only function keys // CURSOR - returns only cursor positioning keys // PUNCT - returns only punctuation marks // ESC - returns only the escape key // the masks can be combined with a logical OR in the call, for example: // if(getfilteredkey(&this_event,U_CASE|NUMBER|FUNCT)) // will return true if the key pressed was an upper case character, a // number, or a function key. If true, the key's ascii code and scan // value are in struct key_event this_event. // ************************************************************************* const char UCASE = 0x1; const char LCASE = 0x2; const char BCASE = 0x4; const char NUMBER = 0x8; const char FUNCT = 0x10; const char CURSOR = 0x20; const char PUNCT = 0x40; const char ESC = 0x80; >>>KEYBOARD.DOC A. Copyright Information Keyboard.Hpp and Keyboard.Cpp along with this document file are copyright 1991 by the Gamers Programming Workshop, GAMERS forum, Compuserve (GO GAMERS, section 11). The code and related document are free for use, distribution, and modification, provided the following conditions are met: 1. no commercial use of this source code or documents is permitted. 2. no fee may be charged beyond disk duplication cost for any of this material. 3. If the code is upgraded or modified a copy of the modification must be uploaded to section 11 of the GAMERS forum on Compuserve. All modifications must be documented and the author's name included in the source code header block, and the subsequent file package must include all the original doc files as well as any additions. If you modify or add functions please update the function list below. B. Description class win { public: char status; // 1 if window opened successfully win(int tlx, int tly, int xwid, int ywid, char *bmap, char brdrwid, char shdwwid, char bgrnd, char border); char installed(){return(status);} // returns the status value ~win(); private: char far *backgrnd; // pointer to background bitmap int origX; // top left x coord of the window int origY; // top left y coord of the window int xsize; // window x dimension in pixels int ysize; // window y dimension in pixels char bdrwid; // border width, 0 if no border char shdwid; // shadow width, 0 if no shadow char shdwon; // 1 if shadow is on, 0 if not char b_grnd; // window background color char brdr; // border color, ignored if bdrwid=0; >>>WIN.DOC A. Copyright Information Images.Hpp and Images.Cpp along with this document file are copyright 1991 by the Gamers Programming Workshop, GAMERS forum, Compuserve (GO GAMERS, section 11). The code and related document are free for use, distribution, and modification, provided the following conditions are met: 1. no commercial use of this source code or documents is permitted. 2. no fee may be charged beyond disk duplication cost for any of this material. 3. If the code is upgraded or modified a copy of the modification must be uploaded to section 11 of the GAMERS forum on Compuserve. All modifications must be documented and the author's name included in the source code header block, and the subsequent file package must include all the original doc files as well as any additions. If you modify or add functions please update the function list below. B. Description class image { public: p_rec palette; // holds the default image palette char fpath[80]; // stores the disk path to image char getstatus() {return(status);} // returns status of last op // 1 if successful, 0 if not protected: char in_ram; // 1 if image in ram, 0 if not char packed; // 1 if packed in ram, 0 if not char status; // returned by getstatus() char far *buffer; // pointer for ram buffer if any class pcx : public image { public: pcx(char *fspec); // constructor char load(char method); // load into ram packed or unpacked void unload(); // unload from ram char display(char fadetype); // display image using fadetype void remove(char fadetype); // remove image using fadetype ~pcx(); // destructor private: char unpacktoram(char far *dest, // internal, unpack to memory unsigned numbytes); if((handle=open(fntfile,O_CREAT|O_BINARY,S_IREAD|S_IWRITE))==-1) { _settextmode(); printf("error creating font file\n"); _settextmode(); return;